package com.yvan.periscope.controller;

import com.yvan.periscope.alert.Coordinator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

@RestController
public class RootController {

    @Autowired
    private Coordinator coordinator;

    @GetMapping("/ok")
    public String ok() {
        return "ok";
    }

    @GetMapping(value = {"/index.htm", "/"})
    public ModelAndView index() {
        return new ModelAndView(new RedirectView("/analytics/summary.htm"));
    }

    @GetMapping("/add")
    public String add() {
        coordinator.add();
        return "ok";
    }

    @GetMapping("/remove")
    public String test() {
        coordinator.remove();
        return "ok";
    }

}
